package com.example.tool.activtiy;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.example.tool.R;
import com.example.tool.activtiy.base.BaseActivity;
import com.example.tool.adapter.DbAdapter;
import com.example.tool.adapter.base.decoration.RecycleViewDivider;
import com.example.tool.source.HandlerActivity;
import com.example.tool.mvp.CommonPresent;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;

/**
 * 描述:andriod原理源码分析
 *
 * @author: liangkun
 * @date: 2019/11/29 10:31
 */
public class SourceOriginalActivtiy extends BaseActivity<CommonPresent> {
    @BindView(R.id.tv_title)
    protected TextView tvTitle;
    @BindView(R.id.rv_public)
    protected RecyclerView recyclerView;
    LinearLayoutManager linearLayoutManager;
    private String[] list = {"滑动与事件分发", "handler源码"};
    private DbAdapter dbAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_public;
    }

    @Override
    protected void initView() {
        tvTitle.setText("源码分析查看");
        linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recyclerView.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.VERTICAL,
                getResources().getDimensionPixelOffset(R.dimen.sw_dp_15), 0, 0,
                getResources().getColor(R.color.color_white)));
        recyclerView.setLayoutManager(linearLayoutManager);
        dbAdapter = new DbAdapter(this, getData());
        recyclerView.setAdapter(dbAdapter);
    }

    private List<String> getData() {
        return new ArrayList<>(Arrays.asList(list));
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initEvent() {

        dbAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                switch (position) {
                    case 0:
                        startToActivity(SourceOriginalActivtiy.this, EventSlipActivity.class);
                        break;
                    case 1:
                        startToActivity(SourceOriginalActivtiy.this, HandlerActivity.class);
                        break;

                }
            }
        });
    }

    @Override
    protected CommonPresent createPresenter() {
        return null;
    }
}
